import Vue from 'vue'
import Router from 'vue-router'
import StroyList from './views/story-list.vue'
import ChapterIndex from './views/chapter-index.vue'
import ChapterDetail from './views/chapter-detail'
import Page404 from './views/404.vue'
import AddChapter from './views/add-chapter.vue'
import AddStory from './views/add-story'
import Layout from './components/layout'
import { chapterIndexToHead } from './utils/web3-ctr';

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      component: Layout,
      children:[
        {
          path: '',
          redirect: 'story-list'
        },
        {
          path: 'story-list',
          name: 'story-list',
          component: StroyList
        },
        {
          path: 'chapter-index',
          redirect: '404'
        },
        {
          path: 'chapter-index/:headaddr',
          name: 'chapter-index',
          component: ChapterIndex
        },
        {
          path: 'chapter-detail',
          redirect: '404'
        },
        {
          path: 'chapter-detail/:addr',
          name: 'chapter-detail',
          component: ChapterDetail
        },
        {
          path: 'add-chapter/:prev',
          name: 'add-chapter',
          component: AddChapter
        },
        {
          path: 'add-story',
          name: 'add-story',
          component: AddStory
        },
        {
          path: '404',
          component: Page404
        }
      ]
    },
    
    // {
    //   path: '/about',
    //   name: 'about',
    //   // route level code-splitting
    //   // this generates a separate chunk (about.[hash].js) for this route
    //   // which is lazy-loaded when the route is visited.
    //   component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
    // }
  ]
})
